/*
 * LiquidBounce Hacked Client
 * A free open source mixin-based injection hacked client for Minecraft using Minecraft Forge.
 * https://github.com/CCBlueX/LiquidBounce/
 */
package net.ccbluex.liquidbounce.features.module.modules.exploit

import net.ccbluex.liquidbounce.event.EventTarget
import net.ccbluex.liquidbounce.event.PacketEvent
import net.ccbluex.liquidbounce.features.module.Module
import net.ccbluex.liquidbounce.features.module.ModuleCategory
import net.ccbluex.liquidbounce.features.module.ModuleInfo

@ModuleInfo(name = "ForceUnicodeChat", description = "Allows you to send unicode messages in chat.", category = ModuleCategory.EXPLOIT)
class ForceUnicodeChat : Module() {

    @EventTarget
    fun onPacket(event: PacketEvent) {
        if (classProvider.isCPacketChatMessage(event.packet)) {
            val chatMessage = event.packet.asCPacketChatMessage()
            val message = chatMessage.message
            val stringBuilder = StringBuilder()

            for (c in message.toCharArray())
                if (c.toInt() in 33..128)
                    stringBuilder.append(Character.toChars(c.toInt() + 65248)) else stringBuilder.append(c)

            chatMessage.message = stringBuilder.toString()
        }
    }

}